﻿/*****************************************************************************
 
 Use of Ext is under the Ext JS license, for more information, 
 please visit http://extjs.com/products/license.php page. 
  
 You should confirm that you have read, understood and accept ethical criteria listed. 
 If not, see <http://www.mvcnext.com/license/>.
  
 Version: 1.0.0.0
 Website: http://www.mvcnext.com/
 
 Copyright (c) Yoganand R. All rights reserved.
 For continued development and updates, visit http://yogsbreath.net
 
 ******************************************************************************/
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Web.UI;
using System.Text;

namespace MVCnExt.Web.UI.Ext
{
    /// <summary>
    /// Reusable data formatting functions
    /// This class is a singleton and cannot be created directly.
    /// </summary>
    public class ExtFormatUtil : ExtConfig
    {
        public override IList<ScriptDescriptor> GetScriptDescriptors()
        {
            IList<ScriptDescriptor> list = base.GetScriptDescriptors();

            ScriptControlDescriptorBase desc = (ScriptControlDescriptorBase)list[0];

            desc.Type = "Ext.util.Format";            

            return list;
        }

        #region Public Properties

        /// <summary>
        /// Converts the first character only of a string to upper case
        /// </summary>
        public String capitalize { get; set; }

        /// <summary>
        /// Converts the first character only of a string to upper case
        /// </summary>
        public String date { get; set; }

        /// <summary>
        /// Returns a date rendering function that can be reused to apply a date format multiple times efficiently
        /// </summary>
        public String dateRenderer { get; set; }

        /// <summary>
        /// Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
        /// </summary>
        public String htmlEncode { get; set; }

        /// <summary>
        /// Converts a string to all lower case letters
        /// </summary>
        public String lowercase { get; set; }

        /// <summary>
        /// Strips all HTML tags
        /// </summary>
        public String stripTags { get; set; }

        /// <summary>
        /// Returns a substring from within an original string
        /// </summary>
        public String substr { get; set; }

        /// <summary>
        /// Trims any whitespace from either side of a string
        /// </summary>
        public String trim { get; set; }

        /// <summary>
        /// Checks a reference and converts it to empty string if it is undefined   
        /// </summary>
        public String undef { get; set; }

        /// <summary>
        /// Converts a string to all upper case letters
        /// </summary>
        public String uppercase { get; set; }

        /// <summary>
        /// Format a number as US currency
        /// </summary>
        public String usMoney { get; set; }

        #endregion
    }
}
